package com.fiill.audioplayer;

import android.media.AudioAttributes;

public final class CarAudioContext {
    /*
     * Shouldn't be used
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.INVALID
     */
    private static final int INVALID = 0;
    /*
     * Music playback
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.INVALID implicitly + 1
     */
    static final int MUSIC = 1;
    /*
     * Navigation directions
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.MUSIC implicitly + 1
     */
    static final int NAVIGATION = 2;
    /*
     * Voice command session
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.NAVIGATION implicitly + 1
     */
    static final int VOICE_COMMAND = 3;
    /*
     * Voice call ringing
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber
     *     .VOICE_COMMAND implicitly + 1
     */
    static final int CALL_RING = 4;
    /*
     * Voice call
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.CALL_RING implicitly + 1
     */
    static final int CALL = 5;
    /*
     * Alarm sound from Android
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.CALL implicitly + 1
     */
    static final int ALARM = 6;
    /*
     * Notifications
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber.ALARM implicitly + 1
     */
    static final int NOTIFICATION = 7;
    /*
     * System sounds
     * ::android::hardware::automotive::audiocontrol::V1_0::ContextNumber
     *     .NOTIFICATION implicitly + 1
     */
    static final int SYSTEM_SOUND = 8;
    /*
     * Emergency related sounds such as collision warnings
     */
    static final int EMERGENCY = 9;
    /*
     * Safety sounds such as obstacle detection when backing up or when changing lanes
     */
    static final int SAFETY = 10;
    /*
     * Vehicle Status related sounds such as check engine light or seat belt chimes
     */
    static final int VEHICLE_STATUS = 11;
    /*
     * Announcement such as traffic announcements
     */
    static final int ANNOUNCEMENT = 12;

    public static int getAudioContextFromAudioContextString(String str){
        if (null == str) return CarAudioContext.MUSIC;
        else if(str.equals("MUSIC")) return CarAudioContext.MUSIC;
        else if(str.equals("NAVIGATION")) return CarAudioContext.NAVIGATION;
        else if(str.equals("VOICE_COMMAND")) return CarAudioContext.VOICE_COMMAND;
        else if(str.equals("CALL_RING")) return CarAudioContext.CALL_RING;
        else if(str.equals("CALL")) return CarAudioContext.CALL;
        else if(str.equals("ALARM")) return CarAudioContext.ALARM;
        else if(str.equals("NOTIFICATION")) return CarAudioContext.NOTIFICATION;
        else if(str.equals("SYSTEM_SOUND")) return CarAudioContext.SYSTEM_SOUND;
        else if(str.equals("EMERGENCY")) return CarAudioContext.EMERGENCY;
        else if(str.equals("SAFETY")) return CarAudioContext.SAFETY;
        else if(str.equals("VEHICLE_STATUS")) return CarAudioContext.VEHICLE_STATUS;
        else if(str.equals("ANNOUNCEMENT")) return CarAudioContext.ANNOUNCEMENT;
        else return CarAudioContext.MUSIC;
    }

    public static int getAudioUsageFromAudioContext(int audio_context){
        if (audio_context == CarAudioContext.MUSIC) return AudioAttributes.USAGE_MEDIA;
        if (audio_context == CarAudioContext.NAVIGATION) return AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
        if (audio_context == CarAudioContext.VOICE_COMMAND) return AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY;
        if (audio_context == CarAudioContext.CALL_RING) return AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
        if (audio_context == CarAudioContext.CALL) return AudioAttributes.USAGE_VOICE_COMMUNICATION;
        if (audio_context == CarAudioContext.ALARM) return AudioAttributes.USAGE_ALARM;
        if (audio_context == CarAudioContext.NOTIFICATION) return AudioAttributes.USAGE_NOTIFICATION;
        if (audio_context == CarAudioContext.SYSTEM_SOUND) return AudioAttributes.USAGE_ASSISTANCE_SONIFICATION;
        if (audio_context == CarAudioContext.EMERGENCY) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.SAFETY) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.VEHICLE_STATUS) return AudioAttributes.USAGE_VOICE_COMMUNICATION;
        if (audio_context == CarAudioContext.ANNOUNCEMENT) return AudioAttributes.USAGE_VOICE_COMMUNICATION;
        else return AudioAttributes.USAGE_MEDIA;
    }

    public static int getDefaultContentTypeFromAudioContext(int audio_context ){
        if (audio_context == CarAudioContext.MUSIC) return AudioAttributes.CONTENT_TYPE_MUSIC;
        if (audio_context == CarAudioContext.NAVIGATION) return AudioAttributes.CONTENT_TYPE_SPEECH;
        if (audio_context == CarAudioContext.VOICE_COMMAND) return AudioAttributes.CONTENT_TYPE_SPEECH;
        if (audio_context == CarAudioContext.CALL_RING) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.CALL) return AudioAttributes.CONTENT_TYPE_SPEECH;
        if (audio_context == CarAudioContext.ALARM) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.NOTIFICATION) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.SYSTEM_SOUND) return AudioAttributes.CONTENT_TYPE_SPEECH;
        if (audio_context == CarAudioContext.EMERGENCY) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.SAFETY) return AudioAttributes.CONTENT_TYPE_SONIFICATION;
        if (audio_context == CarAudioContext.VEHICLE_STATUS) return AudioAttributes.CONTENT_TYPE_SPEECH;
        if (audio_context == CarAudioContext.ANNOUNCEMENT) return AudioAttributes.CONTENT_TYPE_SPEECH;
        else return AudioAttributes.CONTENT_TYPE_MUSIC;
    }

}